<template>
  <div class="table-form">
    <el-form ref="formRef" :model="form" :inline="true" class="pro-select-box">
      <el-form-item label="设备编号:" prop="deviceCode">
        <el-input v-model="form.deviceCode" clearable placeholder="设备编号" />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="query">查询</el-button>
        <!-- <el-button type="primary" @click="output">导出</el-button> -->
        <el-button type="success" @click="addForm" v-permission="['device:add']"
          >新增</el-button
        >
      </el-form-item>
    </el-form>
    <!-- 表格 -->
    <hcTable
      :table-data="list"
      :options="options"
      :columns="tableColumn"
      @size-change="handlerPageSize"
      @current-change="handlerPageIndex"
      @command="handleAction"
    >
    </hcTable>
    <addAndEdit :options="editOption" @closeDialog="closeDialog" />
  </div>
</template>

<script setup>
import { reactive } from "vue";
import addAndEdit from "./dialog/addAndEdit.vue";
import useQueryTable from "@/hooks/useQueryTable";

let form = reactive({
  deviceCode: "",
});

let tableColumn = [
  { type: "index", width: "60", label: "序号", align: "center", fixed: true },
  { prop: "factoryCode", label: "工厂编号", align: "center" },
  { prop: "deviceCode", label: "设备编号", align: "center" },
  { prop: "deviceName", label: "设备名称", align: "center" },
  {
    width: "120",
    label: "操作",
    align: "center",
    buttons: [
      {
        name: "编辑",
        type: "warning",
        command: "edit",
        permission: ["device:edit"],
      },
      {
        name: "删除",
        type: "danger",
        command: "delete",
        permission: ["device:delete"],
      },
    ],
  },
];

let {
  list,
  query,
  addForm,
  options,
  editOption,
  closeDialog,
  handleAction,
  handlerPageSize,
  handlerPageIndex,
} = useQueryTable({ get: "/Device/GetPageList", del: "/Device/Delete" }, form);
</script>

<style lang="scss" scoped></style>
